What is the use of Keep and Peek in “TempData”?
100915-Oct-2019
Updated on 23-Sep-2020
Home / DeveloperSection / Interviews / What is the use of Keep and Peek in “TempData”?
Anonymous User
15-Oct-2019Once “TempData” is read in the current request it’s not available in the subsequent request. If we want “TempData” to be read and also available in the subsequent request then after reading we need to call the “Keep” method as shown in the code below.
The more shortcut way of achieving the same is by using “Peek”. This function helps to read as well advices MVC to maintain “TempData” for the subsequent request.
If you want to read more in detail you can read from this detailed blog on MVC Peek and Keep.